/**
 * 
 */
package SimulLois;

import org.apache.log4j.Logger;

import SimulLois.interfaces.Lois;

/**
 * @author Propriétaire
 * 
 */
public class Geometrique implements Lois {
	
	public static Logger	LOG	= Logger.getLogger(Geometrique.class);
	
	private Double	     p;
	
	public Geometrique(Double p) {
		this.p = p;
	}
	
	public static Double randGeometrique(Double p) {
		
		LOG.info("invocking Geometrique generator");
		
		Double n = new Double(0);
		while (Bernoulli.randBernoulli(p) == 0) {
			n += 1;
		}
		n += 1;
		return n;
	}
	
	/*
	 * (non-Javadoc)
	 * 
	 * @see main.java.SimulLois.interfaces.Lois#gen()
	 */
	@Override
	public Double gen() {
		// TODO Auto-generated method stub
		return randGeometrique(p);
	}
	
	/**
	 * @return the p
	 */
	public Double getP() {
		return p;
	}
	
	/**
	 * @param p
	 *            the p to set
	 */
	public void setP(Double p) {
		this.p = p;
	}
	
}
